import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:龙宝
 * Date:2024-09-22
 * Time:17:32
 */
//冒泡
class Bubble{
    public static void bubble(int[] arr){
        for(int i = 0;i<arr.length-1;i++){
            int flg = 1;
            for(int j = 0;j<arr.length-1-i;j++){
                if(arr[j] > arr[j+1]){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                    flg = 0;
                }
            }
            if(flg == 1){
                break;
            }
        }
    }
}
class Quick{
    public static void Quick(int[] arr, int left, int right){
        if(left >= right){
            return;
        }
        int i = left;
        int j = right;
        //基准
        int base = arr[left];
        while (i < j){
            while (i < j && arr[j] >= base){
                j--;
            }
            while (i < j && arr[i] <= base){
                i++;
            }
            if(i < j){
                int tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
            }
        }
        arr[left] = arr[i];
        arr[i] = base;
        Quick(arr, left, i-1);
        Quick(arr, i+1, right);
    }
}
public class Main {
    public static void main(String[] args) {
        int[] arr = {9,2,3,5,1,0,6,8,7,4};
//        Bubble.bubble(arr);
        Quick.Quick(arr, 0, arr.length-1);
        System.out.println(Arrays.toString(arr));
    }
}
